<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 150px;
            height: 200px;
            background-color: red;
            margin: 150px auto;
            transition: all 0.5s ease 0s;
        }
    </style>
</head>

<body>
    <div id="box"></div>
    <script>
        var box = document.getElementById('box');
        var gu = (rui, { x = 0, y = 0 } = {}, end = () => { }) => {
            rui.style.transform = `translate3d(${x}px,${y}px,0)`;
            rui.addEventListener('transitionend',
                () => {
                    end();
                },
                false
            );
        }
        var xiang = (rui, object) => {
            return new Promise((resolve) => {
                gu(rui, object, () => {
                    resolve();
                });
            });
        }
        console.log(xiang(box,{}))
        var r5 = document.addEventListener('click', () => {
            console.log(0)
            xiang(box, { x: 150 })
                // new Promise((resolve)=>{
                //     gu(box,
                //     {x:150},()=>{
                //         resolve();
                //     });
                .then((r1) => {
                    console.log(1, r1)
                  return  xiang(box,{x:150,y:150})
                    }).then((r2) => {
                        console.log(2, r2)
                        return xiang(box, {y:150})
                        
                    }).then((r3) => {
                        console.log(3)
                        return xiang(box, {})
                    })
                }, false);

    </script>
</body>

</html>